package ${projectConfig.beanPackage}.${config.model}.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.HashMap;

import ${projectConfig.beanPackage}.${config.model}.dao.gen.${config.objectName}Dao;
import ${projectConfig.beanPackage}.${config.model}.bean.po.gen.${config.objectName};
import ${projectConfig.beanPackage}.${config.model}.service.I${config.objectName}Service;
import ${projectConfig.commPackage}.bean.PageBean;



@Service("${config.objectName}Service")
public class ${config.objectName}ServiceImpl implements I${config.objectName}Service {
	@Autowired
	private ${config.objectName}Dao ${config.objectName?uncap_first}Dao;

<#list pks as prop>
	@Override
	public ${config.objectName} queryObject(${prop.javaType}  ${prop.alias}){
		return ${config.objectName?uncap_first}Dao.selectByPrimaryKey( ${prop.alias});
	}

	public ${config.objectName} queryObject(Map<String, Object> map){
		return ${config.objectName?uncap_first}Dao.selectByMap( map);
	}
	
	@Override
	public List<${config.objectName}> queryList(Map<String, Object> map){
		return ${config.objectName?uncap_first}Dao.getListByMap(map);
	}

    @Override
    public PageBean getPageBeanByMap(Map map,int pageNo,int pageSize) {
		return ${config.objectName?uncap_first}Dao.getPageBeanByMap(map, pageNo, pageSize);
    }


	@Override
	public int queryTotal(Map<String, Object> map){
		return ${config.objectName?uncap_first}Dao.countTotalByMap(map);
	}
	
	@Override
	public void save(${config.objectName} ${config.objectName?uncap_first}){
		${config.objectName?uncap_first}Dao.insertSelective(${config.objectName?uncap_first});
	}
	
	@Override
	public void update(${config.objectName} ${config.objectName?uncap_first}){
		${config.objectName?uncap_first}Dao.updateByPrimaryKeySelective(${config.objectName?uncap_first});
	}
	
	@Override
	public void delete(${prop.javaType}  ${prop.alias}){
		${config.objectName?uncap_first}Dao.deleteByPrimaryKey(${prop.alias});
	}

	@Override
	public void delete(Map<String, Object>  map){
	${config.objectName?uncap_first}Dao.deleteByMap(map);
	}
	
	@Override
	public void deleteBatch(${prop.javaType}[]  ${prop.alias}s){
		Map<String, Object> map = new HashMap<>();
		map.put("${prop.alias}_in",${prop.alias}s);
		${config.objectName?uncap_first}Dao.deleteByMap(map);
	}
	</#list>
	
}
